//CLASE ACTUALMENTE OBSOLETA
package com.pinapel.aixml.models.xml;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.sax.SAXSource;

import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;

import com.pinapel.aixml.ui.tree.XMLTrimFilter;

public class DOMUtil {
	 
	   public static Document createDocument(InputSource is) throws Exception{ 
	        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
	        factory.setIgnoringComments(true);
	        factory.setIgnoringElementContentWhitespace(true);
	        factory.setCoalescing(true);
	        //factory.setValidating(true);
	        DocumentBuilder builder = factory.newDocumentBuilder(); 
	        
	        return builder.parse(is); 
	    }
//	public static Document createDocument(InputSource is) throws Exception{ 
//        SAXParserFactory saxFactory = SAXParserFactory.newInstance(); 
//        SAXParser parser = saxFactory.newSAXParser(); 
//        XMLReader reader = new XMLTrimFilter(parser.getXMLReader()); 
// 
//        TransformerFactory factory = TransformerFactory.newInstance(); 
//        Transformer transformer = factory.newTransformer(); 
//        transformer.setOutputProperty(OutputKeys.INDENT, "no"); 
//        DOMResult result = new DOMResult(); 
//        transformer.transform(new SAXSource(reader, is), result); 
//        return (Document)result.getNode(); 
//    } 
	 
}
